#ifndef _AT24C32_H_
#define _AT24C32_H_

#include <stdint.h>

typedef struct at24c32 {
	struct {
		struct {
			int device_address;
		} fix;
		struct {
			int res;
		} var;
	} cfg;
	struct {
		/**
		 * memory_address 正常情况下是直接使用 uint8_t 类型的
		 * 这里使用指针是是为了增加一个 NULL 状态，表明本次通信不需要发送 memory 地址
		 * 比如说 current address read 和 sequential read 就是不需要发送 memory 地址的
		 */
		int (*i2c_read)(uint8_t device_address, uint16_t* memory_address, uint8_t* buffer, uint32_t length);
		int (*i2c_write)(uint8_t device_address, uint16_t* memory_address, uint8_t* buffer, uint32_t length);
	} ops;
} at24c32_t;

int at24c32_set_current_address(at24c32_t* eeprom, uint16_t address);
int at24c32_byte_write(at24c32_t* eeprom, uint16_t address, uint8_t* buffer);
int at24c32_page_write(at24c32_t* eeprom, uint16_t address, uint8_t* buffer, uint8_t length);
int at24c32_current_address_read(at24c32_t* eeprom, uint8_t* buffer);
int at24c32_random_read(at24c32_t* eeprom, uint16_t address, uint8_t* buffer);
int at24c32_sequential_read(at24c32_t* eeprom, uint8_t* buffer, uint16_t length);

#endif /* _AT24C32_H_ */
